home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Graphics 2D / Restore Screen Cluts / ColorReset.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  13.5 KB  |  359 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        ColorReset.h
  3.  
  4.     Contains:    Main header file for the ClassicImage application
  5.  
  6.     Written by:  Forrest Tanaka    
  7.  
  8.     Copyright:    Copyright © 1988-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/13/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. #ifndef __CLASSICIMAGE__
  24. #define __CLASSICIMAGE__
  25.  
  26.     
  27.  
  28. /******************************************************************************\
  29. * Header Files
  30. \******************************************************************************/
  31.  
  32. #ifndef __STANDARDFILE__
  33. #include <StandardFile.h>
  34. #endif
  35.  
  36. #ifndef __WINDOWS__
  37. #include <Windows.h>
  38. #endif
  39.  
  40.  
  41. /******************************************************************************\
  42. * Constants
  43. \******************************************************************************/
  44.  
  45. #define kScrollBarWidth 16 /* Number of pixels wide a scroll bar is */
  46.  
  47. /* Alert types */
  48. #define kGenericAlert 0 /* Display a generic alert */
  49. #define kNoteAlert    1 /* Display the note alert */
  50. #define kCautionAlert 2 /* Display the caution alert */
  51. #define kStopAlert    3 /* Display the stop alert */
  52.  
  53. /* Alert button options */
  54. #define rOKAlertID       6010 /* Resource ID of OK alert */
  55. #define rOKCancelAlertID 6011 /* Resource ID of OK/Cancel alert */
  56. #define rSaveAlertID     6012 /* Resource ID of Save/Cancel/Don’t Save alert */
  57.  
  58. /* Button item numbers */
  59. #define kSaveButton       1 /* Item number of Save button */
  60. #define kCancelSaveButton 2 /* Item number of Cancel button for saves */
  61. #define kDontSaveButton   3 /* Item number of Don’t Save button */
  62.  
  63. /* Memory error message constants */
  64. #define rMemErrMessages    1000 /* Resource ID of memory error msg STR# */
  65. #define kMemErrAppOpenMsg  1    /* Not enough memory to open application */
  66. #define kMemErrOpenDocMsg  2    /* Not enough memory to open a document */
  67.  
  68. /* Resource error message constants */
  69. #define rResErrMessages     1001 /* Resource ID of resource err message STR# */
  70. #define kResErrAppDamageMsg 1    /* Application is damaged */
  71.  
  72. /* Miscellaneous error message constants */
  73. #define rMiscErrMessages   1002 /* Resource ID of misc. error message STR# */
  74. #define kMiscErrUnknownMsg 1    /* Unknown error */
  75. #define kMiscErrNoQTMsg    2    /* QuickTime not available */
  76. #define kMiscQuickTimeMsg  3    /* Some sort of QuickTime error */
  77.  
  78. /* File error message constants */
  79. #define rFileErrMessages   1003 /* Resource ID of file error message STR# */
  80. #define kFileErrDocOpenMsg 1    /* Document is already open elsewhere */
  81.  
  82.  
  83. /******************************************************************************\
  84. * Macros
  85. \******************************************************************************/
  86.  
  87. #ifdef applec
  88. #define topLeft(r) (*((Point *) &(r).top))
  89. #define botRight(r) (*((Point *) &(r).bottom))
  90. #endif
  91.  
  92. #define hiWord(a) ((short) (((unsigned long) a) >> 16L))
  93. #define loWord(a) ((short) ((unsigned long) a))
  94.  
  95.  
  96. /******************************************************************************\
  97. * Global Variables
  98. \******************************************************************************/
  99.  
  100. extern Boolean gQuitting;            /* True if user requested that app quit */
  101. extern Boolean gWereInFront;         /* True if this application is frontmost */
  102. extern Boolean gFixMenus;            /* True if menus need fixing */
  103. extern Boolean gHasAppleEvents;      /* True if Apple Events implemented */
  104. extern Boolean gHasCoolSF;           /* True if 7.0 Standard File available */
  105. extern ControlActionUPP gActionProc;
  106. extern QDBitsUPP        gQDBitsUPP;
  107. extern QDGetPicUPP      gQDGetPicUPP;
  108. extern QDPutPicUPP      gQDPutPicUPP;
  109.  
  110.  
  111. /******************************************************************************\
  112. * DoQuit - Handle Quit request from the user
  113. *
  114. * When the user requests that this application should quit, DoQuit is called to
  115. * perform the Quit command.  All open document windows and desk accessory
  116. * windows (only applicable before system software version 7.0) are closed and
  117. * the gQuitting global variable is set to true.
  118. \******************************************************************************/
  119.  
  120. void DoQuit(void);
  121.  
  122.  
  123. /******************************************************************************\
  124. * IsDAWindow - Test to see whether a window belongs to a DA or not
  125. *
  126. * If the window specified by aWindow belongs to a desk accessory, then
  127. * IsDAWindow returns true, otherwise it returns false.  If aWindow is nil, then
  128. * IsDAWindow returns false.
  129. \******************************************************************************/
  130.  
  131. Boolean IsDAWindow(
  132.     WindowPtr aWindow);
  133.  
  134.  
  135. /******************************************************************************\
  136. * DoUpdateEvt - Handle an update event for any window
  137. *
  138. * When an update event is received, DoUpdateEvt is called to handle the
  139. * redrawing of the window that caused the update event.  DoUpdateEvt determines
  140. * the kind of window that needs updating and calls the routine that handles that
  141. * kind of window to draw it.  The anEvent parameter contains the update event.
  142. \******************************************************************************/
  143.  
  144. void DoUpdateEvt(
  145.     EventRecord *anEvent);
  146.  
  147.  
  148. /******************************************************************************\
  149. * DoActivateEvt - Handle an activate event for any window
  150. *
  151. * DoActivateEvt is called when an active event is received for the window
  152. * specified by eventWind.  becomingActive is TRUE if the window is becoming
  153. * activated.  It’s FALSE if the window is becoming inactive.
  154. \******************************************************************************/
  155.  
  156. void DoActivateEvt(
  157.     WindowPtr eventWindow,
  158.     Boolean   becomingActive);
  159.  
  160.  
  161. /******************************************************************************\
  162. * ShowAlert - Show an alert
  163. *
  164. * This routine puts up a an alert with a specified message.  alertType specifies
  165. * which kind of icon to display in the upper-left corner of the alert.
  166. * kGenericAlert specifies that no icon should be displayed.  kNoteAlert
  167. * specifies that the note icon should be displayed.  kCautionAlert specifies
  168. * that the caution icon should be displayed.  kStopAlert specifies that the stop
  169. * icon should be displayed.
  170. *
  171. * buttonOption specifies what buttons should be offered.  rOKAlertID specifies
  172. * that only an OK button should be offered.  rOKCancelAlertID specifies that
  173. * both an OK and a Cancel button should be offered.
  174. *
  175. * messageClass specifies the STR# resource ID which contains the message to
  176. * display and messageIndex specifies the index (the first message is index 1)
  177. * into that STR# of the message to display.
  178. *
  179. * The alert window is placed into alert position on the screen containing most
  180. * of the window specified by parentWindow, or the main screen if parentWindow is
  181. * nil.
  182. \******************************************************************************/
  183.  
  184. short ShowAlert(
  185.     short alertType,
  186.     short buttonOption,
  187.     short messageClass,
  188.     short messageIndex);
  189.  
  190.  
  191. /******************************************************************************\
  192. * TrapExists - Determine whether a trap is implemented
  193. *
  194. * If the trap specified by theTrap is implemented, then TrapExists returns true.
  195. * Otherwise, false is returned.
  196. \******************************************************************************/
  197.  
  198. Boolean TrapExists(
  199.     short theTrap);
  200.  
  201.  
  202. /******************************************************************************\
  203. * FileSpecGet
  204. *
  205. \******************************************************************************/
  206.  
  207. Boolean FileSpecGet(
  208.     FileFilterProcPtr fileFilter,
  209.     short             numTypes,
  210.     SFTypeList        typeList,
  211.     StandardFileReply *retReply);
  212.  
  213.  
  214. /******************************************************************************\
  215. * ConvertOldToNewSFReply - Convert old SFReply record to new StandardFileReply record
  216. *
  217. * The old SFReply record passed in oldReply is converted to the new
  218. * StandardFileReply record that was introduced with system software version 7.0.
  219. * The resulting StandardFileReply record is returned in the newReply parameter.
  220. * If any errors occur, the error code is returned and newReply is untouched.
  221. *
  222. * The following conversions are done:
  223. *
  224. * StandardFileReply            SFReply
  225. * -----------------            -------
  226. * Boolean    sfGood        <-  Boolean good
  227. * Boolean    sfReplacing   <-  true if file exists, false if not
  228. * OSType     sfType        <-  OSType  fType
  229. * FSSpec     sfFile 
  230. *     vRefNum;             <-  real vRefnum from (short vRefNum)
  231. *     parID;               <-  real dirID from (short vRefNum)
  232. *     name;                <-  Str63   fName
  233. * ScriptCode sfScript      <-  iuSystemScript
  234. * short      sfFlags       <-  0
  235. * Boolean    sfIsFolder    <-  false
  236. * Boolean    sfIsVolume    <-  false
  237. * long       sfReserved1   <-  0
  238. * short      sfReserved2   <-  0
  239. *
  240. * The setting of sfScript to iuSystemScript I believe is incorrect, but I also
  241. * believe that it’s the best that can be done.  There’s no reliable way to tell
  242. * which script a user was using when he or she typed in the file name in the
  243. * Standard File dialog.  So, GUESS!
  244. \******************************************************************************/
  245.  
  246. OSErr ConvertOldToNewSFReply(
  247.     SFReply           *oldReply,
  248.     StandardFileReply *newReply);
  249.  
  250.  
  251. /******************************************************************************\
  252. * EqualFSSpec - Check equality of FSSpec records
  253. *
  254. * EqualFSSpec returns TRUE if the file specified by spec1 refers to the same
  255. * file as the one specified by spec2.  Otherwise, EqualFSSpec returns FALSE.
  256. \******************************************************************************/
  257.  
  258. Boolean EqualFSSpec(
  259.     FSSpecPtr spec0,
  260.     FSSpecPtr spec1);
  261.  
  262.  
  263. /******************************************************************************\
  264. * CmdPeriodEvent - Detect whether an event is a command-period
  265. *
  266. * This routine determines whether the event passed in anEvent was caused by the
  267. * user typing command-period.  If it was, then true is returned, otherwise false
  268. * is returned.
  269. \******************************************************************************/
  270.  
  271. Boolean CmdPeriodEvent(
  272.     EventRecord *anEvent);
  273.  
  274.  
  275. /******************************************************************************\
  276. * FakeButtonHit - Visually simulate the click of a button
  277. *
  278. * This routine is used to hilight a button for one-tenth of a second to visually
  279. * simulate the click of the mouse on the button passed in the buttonControl
  280. * parameter.  This is normally used when the Enter or Return key is pressed when
  281. * a dialog box is up.  The default button must be momentarily hilighted to show
  282. * the user what he or she actually did.
  283. \******************************************************************************/
  284.  
  285. void FakeButtonHit(
  286.     ControlHandle buttonControl);
  287.  
  288.  
  289. /******************************************************************************\
  290. * Public: CreateGrafPort
  291. *
  292. * Most of this code is very similar to the code in Macintosh Technical Note #41
  293. * “Drawing Into an Off-Screen BitMap.
  294. \******************************************************************************/
  295.  
  296. GrafPtr CreateGrafPort(
  297.     Rect *bounds);
  298.  
  299.  
  300. /******************************************************************************\
  301. * DisposeGrafPort
  302. *
  303. * DisposeGrafPort disposes of the GrafPort specified by doomedPort.  The visRgn,
  304. * clipRgn, bit image, and the GrafPort structure itself must all be disposed of.
  305. * ClosePort is called to dispose of the visRgn and clipRgn.  The bit image and
  306. * GrafPort itself are normal non-relocatable blocks of memory, so they’re just
  307. * disposed of through DisposePtr.
  308. \******************************************************************************/
  309.  
  310. void DisposeGrafPort(
  311.     GrafPtr doomedPort);
  312.  
  313.  
  314. /******************************************************************************\
  315. * NAME & SYNOPSIS:
  316. * RestoreColorsPalette: Restore all screens to the default color table
  317. *
  318. * PARAMETERS:
  319. * None
  320. *
  321. * DEFINITION:
  322. * RestoreColorsPalette sets the color tables of all screens to the default
  323. * colors by using the Palette Manager.  Direct-color screens and screens which
  324. * already have the default set of colors are unaffected.  It’s assumed that
  325. * Color QuickDraw is available, and 32-Bit QuickDraw 1.0 and/or system software
  326. * version 6.0.5 and beyond is available.
  327. *
  328. * RETURN VALUES:
  329. * None
  330. \******************************************************************************/
  331.  
  332. void RestoreColorsPalette(void);
  333.  
  334.  
  335. /******************************************************************************\
  336. * NAME & SYNOPSIS:
  337. * RestoreColorsSlam: Restore all screens to the default color table
  338. *
  339. * PARAMETERS:
  340. * None
  341. *
  342. * DEFINITION:
  343. * RestoreColorsSlam sets the color tables of all screens to the default colors
  344. * by using low-level calls.  All screens are redrawn when this routine is
  345. * called.  Also, if the color table has been changed and then RestoreColorsSlam
  346. * is called to reset them, all screens are still redrawn when the application
  347. * quits.  It’s assumed that Color QuickDraw is available, and 32-Bit QuickDraw
  348. * 1.0 and/or system software version 6.0.5 and beyond is available.
  349. *
  350. * RETURN VALUES:
  351. * None
  352. \******************************************************************************/
  353.  
  354. void RestoreColorsSlam(void);
  355.  
  356.  
  357. #endif
  358.